package reflect;

import reflect.annotations.AutoRunMethod;

import java.lang.reflect.Method;

public class Test3 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");
        Method[] methods = cls.getMethods();
        Object obj = cls.newInstance();
        for(Method method:methods){
            boolean mark = method.isAnnotationPresent(AutoRunMethod.class);
            if(mark){
                System.out.println("调用方法:"+method.getName());
                method.invoke(obj);
            }
        }
    }
}
